#include  <cstdio>
#include  <map>
using std::map;

map<int,int> dic;
map<int,int> res;

int a(int n)
{
	if(n == 0)
		return 0;
	if( res.count(n) != 0)
		return res[n];

	int k = a(n-1);
	if(k - n > 0 && dic.count(k-n) == 0)
	{
		res[n] = k-n;
		dic[k-n] = 1;
	}
	else
	{
		res[n] = k+n;
		dic[k+n] = 1;
	}
	return res[n];
}

int main(int argc, char *argv[])
{
	int k;
	while( scanf("%d",&k) && k != -1 )
		printf("%d\n",a(k));
}
